package com.songsong.myblog2.service.impl;

import com.songsong.myblog2.domain.Archives;
import com.songsong.myblog2.mapper.ArchivesMapper;
import com.songsong.myblog2.service.ArchivesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service(value = "archivesService")
public class ArchivesServiceImpl implements ArchivesService {
    /*注入mapper*/
    @Resource(name = "archivesMapper")
    private ArchivesMapper archivesMapper;

    /**
     * 查找归档
     *
     * @param archivesName
     * @return
     */
    @Override
    public boolean selectArchive(String archivesName) {
        String archive = archivesMapper.selectArchive(archivesName);
        if (archive == null) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 新增归档
     *
     * @param archivesName
     */
    @Override
    public void addArchives(String archivesName) {
        archivesMapper.addArchives(archivesName);
    }

    /**
     * 更改归档数量
     *
     * @param archiveName
     */
    @Override
    public void updateArchiveNum(String archiveName) {
        archivesMapper.updateArchiveNum(archiveName);
    }

    @Override
    public List<Archives> getAllArchives() {
        List<Archives> allArchives = archivesMapper.getAllArchives();
        return allArchives;
    }
}
